
#ifndef __IPEDIT_H__
#define __IPEDIT_H__
#include "..\DuiLib\UIlib.h"
using namespace DuiLib;


#define DotWidth 5
#define EditColor 

class CEditWnd : public CWindowWnd
{
public:
	CEditWnd();

	void Init(CEditUI* pOwner);
	RECT CalPos();

	LPCTSTR GetWindowClassName() const;
	LPCTSTR GetSuperClassName() const;
	void OnFinalMessage(HWND hWnd);

	LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
	LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnEditChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

protected:
	CEditUI* m_pOwner;
	HBRUSH m_hBkBrush;
	bool m_bInit;
};

class  CIPEditUI : public CEditUI
{
public:
	CIPEditUI();

	LPCTSTR GetClass() const;
	LPVOID GetInterface(LPCTSTR pstrName);
	UINT GetControlFlags() const;
	void DoEvent(TEventUI& event);
	void OnChar(TEventUI& event);
	void ToNext( bool bReverse = false);
	void SetNextEdit(CIPEditUI* pEdit);
	void SetFrontEdit(CIPEditUI* pEdit);
private:

	CIPEditUI* m_pNextEdit;
	CIPEditUI* m_pFrontEdit;
	bool m_bInRange;
};

class CIPAddress :public CContainerUI
{

public:
	CIPAddress();
	LPCTSTR GetClass()const;
	LPVOID GetInterface();
	CDuiString GetIPText()const;
	UINT GetIP()const;
	void SetIPText(UINT nIP);
	void SetAttribute(LPCTSTR pstrName ,LPCTSTR pstrValue);
	void SetPos(RECT rcPos);
	void SetBkColor(DWORD dwColor);
	void InitEditItem();
	//void SetPadding(RECT rcPadding);
	//void SetFixedWidth(int cx);
	//void SetFixedHeight(int cy);
	//void DoEvent(TEventUI& event);
	void AdjustPos();
	void SetFont(int nIndex);
private:
	int m_nWidth;
	int m_nHeight;
	CContainerUI* m_pIP;
	CIPEditUI* m_pItem1;
	CIPEditUI* m_pItem2;
	CIPEditUI* m_pItem3;
	CIPEditUI* m_pItem4;
	CContainerUI* m_pParent;
	RECT m_rcPanel;
	RECT ResetItem(CIPEditUI* pItem ,int nIndex);
};
#endif // __IPEDIT_H__